package com.ea.admin.service;

import lombok.Data;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;

import java.util.concurrent.atomic.AtomicInteger;

public interface SseService {
    SseEmitter connect(Long userId);

    void sendMessage(Long userId, String clientId, SseEmitter sseEmitter);

    void closeSseConnect(String clientId);

    @Data
    class SseData {
        String clientId;
        Long userId;
        SseEmitter sseEmitter;
        AtomicInteger sendCount = new AtomicInteger(0);

        public int incrementSendCount() {
            return sendCount.incrementAndGet();
        }
    }
}

